/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 30318
 * Date: 2023-11-15
 * Time: 20:23
 */
import java.util.Scanner;

public class LuckyUser {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        System.out.println("*************   抽奖活动   *************");
        System.out.println("请输入参与抽奖的4位数字：");

        int cardNumber = input.nextInt();
        while(cardNumber / 10000 != 0) {
            System.out.println("您输入的数字错误，请重新输入4位数字：");
            cardNumber = input.nextInt();
        }
        //判断是否为幸运客户
        int a = cardNumber % 10;
        int b = cardNumber / 1000;
        int c = cardNumber / 100 % 10;
        int d = cardNumber / 10 % 10;
        int sum = a + b + c + d;
        System.out.println("该用户是幸运客户吗？");

        if (sum > 20) {
            System.out.println("true");
            //随机生成中奖号码
            int rewardNumber = (int) (Math.random() * 100);

            int rewardOnesPlace = rewardNumber % 10;//个位
            int rewardTensPlace = rewardNumber / 10;//十位
            System.out.println("一等奖中奖尾数为：" + rewardNumber);

            int cardOnesPlace = cardNumber % 10;//个位
            int cardTensPlace = (cardNumber / 10) % 10;//十位

            //判断是否获奖
            if ((cardNumber % 100) == rewardNumber || cardOnesPlace == rewardTensPlace && cardTensPlace == rewardOnesPlace) {
                System.out.println("会员卡后四位为：" + cardNumber + "获得一等奖");
            } else if (cardOnesPlace == rewardOnesPlace || cardTensPlace == rewardTensPlace) {
                System.out.println("会员卡后四位为：" + cardNumber + "获得二等奖");
            } else if (cardOnesPlace == rewardTensPlace || cardTensPlace == rewardOnesPlace) {
                System.out.println("会员卡后四位为：" + cardNumber + "获得三等奖");
            } else {
                System.out.println("会员卡后四位为：" + cardNumber + "很遗憾您没有中奖。");
            }
        } else {
            System.out.println("false");
        }
        System.out.println("*************   感谢参与   *************");
    }
}